package heritage.single.table;

import java.util.Date;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;

public class Application {

	public static void main(String[] args) {
		
		EntityManagerFactory emf = Persistence.createEntityManagerFactory("ophidia"); 
		EntityManager em = emf.createEntityManager(); 
		EntityTransaction tx = em.getTransaction(); 
		tx.begin(); 
		
		Compte cc1 = new CompteCourant("cc1", new Date(), 5000, 1000);
		em.persist(cc1);
		
		Compte ce1 = new CompteEpargne("ce1", new Date(), 10000, 2.3);
		em.persist(ce1);
		
		tx.commit();
		
		
		Compte compteCourant = em.find(CompteCourant.class, "cc1");
		System.out.println(compteCourant);
		
		Compte compteEpargne = em.find(CompteEpargne.class, "ce1");
		System.out.println(compteEpargne);
		
		
		em.close(); 
		emf.close(); 
	}
}
